package netty.chat.service;

import netty.chat.protocal.ProtocalMsg;
import netty.chat.utils.C;

/**
 */
public class ProtocalService {

    private static ProtocalService instance = new ProtocalService();

    private ProtocalService(){

    }

    public static ProtocalService getInstance(){
        return instance;
    }

    public ProtocalMsg buildProtocalMsg(String fromUserId,String toUserId,String content,byte msgType){
        ProtocalMsg pms = new ProtocalMsg();
        pms.setContent(content);
        pms.setFromUserId(fromUserId);
        pms.setToUserId(toUserId);
        pms.setMsgType(msgType);
        return pms;
    }

    public ProtocalMsg buildOnlineMsg(String fromUserId){
        return buildProtocalMsg(fromUserId,"","", C.MSG_TYPE_ONLINE);
    }

    public ProtocalMsg buildSingleMsg(String fromUserId,String toUserId,String content){
        return buildProtocalMsg(fromUserId,toUserId,content, C.MSG_TYPE_SEND_MSG);
    }

}
